﻿#region Copyright and Licensing Notice
// Copyright (C) 2011 Steven Bosnick
// 
// This program is open source software; you can redistribute it 
// and/or modifiy it under the terms of the Eclipse Public License,
// version 1.0.
// 
// This program is distributed in the hope that it will be useful, 
// but WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A 
// PARTICULAR PURPOSE. See the Eclipse Public License for more
// details.
// 
// You should have received a copy of the Eclipse Public License 
// along with this program; if not, you can find a copy at
// "http://www.opensource.org/licenses/eclipse-1.0.php".
#endregion
using System;
using System.Runtime.Serialization;
using BitwiseOre.SharedMemory.JetBrains;

namespace BitwiseOre.SharedMemory
{
    ///<summary>
    /// The exception that is thrown when an attempt is made to create a 
    /// <see cref="SharedMemoryListener"/> for a name that is already in use.
    ///</summary>
    [Serializable,UsedImplicitly(ImplicitUseTargetFlags.WithMembers)]
    public sealed class NameAlreadyInUseException : SharedMemoryException
    {
        ///<summary>
        /// Initializes a new instances of the <see cref="NameAlreadyInUseException"/> class.
        ///</summary>
        public NameAlreadyInUseException()
        {
        }

        ///<summary>
        /// Initalizes a new instances of the <see cref="NameAlreadyInUseException"/> class with a
        /// specfied error message and, optionally, the listener name.
        ///</summary>
        ///<param name="message">
        ///     A string that contains the error message that explains the reason for the exception.
        /// </param>
        public NameAlreadyInUseException(string message) : base(message)
        {
        }

        ///<summary>
        /// Initalize a new instance of the <see cref="NameAlreadyInUseException"/> class with a 
        /// specified error message and the inner exception.
        ///</summary>
        ///<param name="message">
        ///     A string that contains the error message that explains the reason for the exception.
        /// </param>
        ///<param name="inner">
        ///     The exception that caused the current exception to be thrown.
        /// </param>
        public NameAlreadyInUseException(string message, Exception inner) : base(message, inner)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="NameAlreadyInUseException"/> class with the 
        /// specified serialization information and streaming context. 
        /// </summary>
        /// <param name="info">
        ///     The SerializationInfo that contains all the data required to serialize the exception. 
        /// </param>
        /// <param name="context">
        ///     The StreamingContext that specifies the source and destination of the stream. 
        /// </param>
        private NameAlreadyInUseException(SerializationInfo info, StreamingContext context) : base(info, context)
        {
        }
    }
}